#include<bits/stdc++.h>

using namespace std;
int D[2][13] = {
        {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
        {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
};

bool leap(int y) {
    return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
}

int main() {
    assert(leap(2000));
    assert(!leap(2022));

    assert(sizeof(D[0]) / sizeof(D[0][0]) == 13);
    int y, m, d;
    int days;
    cin >> y >> m >> d;
    days = 0;
    for (int i = 1; i < m; i++) {
        days += D[leap(y)][i];
    }
    days += d;
    cout << days;

    return 0;
}
